package com.coolingme.jdkoberver;

import java.util.Observable;
import java.util.Observer;

/**
 * 博主，观察者
 *
 * @author wangyue
 * @date 2020-10-01 23:30
 */
public class Blogger implements Observer {

    private String name;

    public Blogger(String name) {
        this.name = name;
    }

    @Override
    public void update(Observable o, Object arg) {
        // 被观察者
        CSDN csdn = (CSDN) o;
        // 传递的参数：问题
        Question question = (Question) arg;

        System.out.println("-----------------------");
        System.out.println("你好：" + this.name + "\n" +
                "您有一个来自\"" + question.getUserName() + "\"的提问，问题内容如下：\n" +
                question.getContent());
    }
}
